module.exports = contentNavigationService;// 内容导航服务。
var contentNavigationService = {
  resultPage: "/pages/resultPage/resultPage",
  statisticsPage: "/pages/statisticsPage/statisticsPage",
  writeInPage: "/pages/writeInPage/writeInPage",
  writePage: "/pages/writePage/writePage",

  // 导航参数。
  navigationParameter: null,

  // 导航。
  // pageKey: 目标页面pageKey, string
  navigateToAsync: function (pageKey, parameter) {
    var navigationParameter = null;
    if (parameter != undefined) {
      navigationParameter = {
        pageKey: pageKey,
        parameter: parameter
      }
    }
    contentNavigationService.navigationParameter = navigationParameter;

    wx.navigateTo({
      url: pageKey,
    })
  },
  // 获取导航参数。
  // pageKey: 目标页面pageKey, string
  getParameter: function (pageKey) {
    if (contentNavigationService.navigationParameter == null || contentNavigationService.navigationParameter.pageKey != pageKey) {
      return null;
    }

    var parameter = contentNavigationService.navigationParameter.parameter;
    contentNavigationService.navigationParameter = null;
    return parameter;
  },
  //返回上一级或多级页面
  //pageNum:返回页面数  int
  navigateBackAsync:function(pageNum){
    wx.navigateBack({
      delta: pageNum
    })
  }
  
};

module.exports = contentNavigationService;